#include<iostream>
#include<pthread.h>
#include<unistd.h>
#include<string>

using std::cout;
using std::endl;
using std::cerr;
using std::string;

void* pthreadFun1(void* argc){
    string str=(char*)argc;
    while(true)
    {
        cout<<str<<"My pid::"<<getpid()<<endl;
        sleep(1);
    }

}
void* pthreadFun2(void* argc){
    string str=(char*)argc;
    while(true)
    {
        cout<<str<<"My pid::"<<getpid()<<endl;
        sleep(1);
    }
}

int main()
{
    pthread_t pth1,pth2;
    pthread_create(&pth1,nullptr,pthreadFun1,(void*)"I am pthread1!");
    pthread_create(&pth2,nullptr,pthreadFun2,(void*)"I am pthread2!");
    sleep(1);

    while(true){
        cout<<"Main pthread has gone!"<<"My pid::"<<getpid()<<endl;
        sleep(1);
    }

    pthread_join(pth1,nullptr);
    pthread_join(pth2,nullptr);
    return 0;
}
